package com.newenergy.wisehome.ui.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.newenergy.wisehome.R;
import com.newenergy.wisehome.config.AppManager;
import com.newenergy.wisehome.data.bean.DeviceCategory;

import butterknife.BindView;
import butterknife.OnClick;
import me.yokeyword.fragmentation.ISupportFragment;

/**
 * Created by kyx on 2018/5/4.
 * 养生盆操作界面--7209
 */

public class HealthBasinFragment extends BaseFragment {

    private static String ARG_HEALTHBASIN="arg_healthbasin";
    @BindView(R.id.btn_back)
    Button mBtnBack;
    @BindView(R.id.tv_back)
    TextView mTvBack;
    @BindView(R.id.tv_page)
    TextView mTvPage;
    @BindView(R.id.btn_healthbasin_switch)
    Button mBtnHealthbasinSwitch;
    @BindView(R.id.btn_healthbasin_mode)
    Button mBtnHealthbasinMode;
    @BindView(R.id.btn_healthbasin_timing)
    Button mBtnHealthbasinTiming;
    @BindView(R.id.btn_healthbasin_control)
    Button mBtnHealthbasinControl;
    @BindView(R.id.btn_healthbasin_bubble)
    Button mBtnHealthbasinBubble;
    @BindView(R.id.btn_healthbasin_spa)
    Button mBtnHealthbasinSpa;
    @BindView(R.id.btn_healthbasin_tem)
    Button mBtnHealthbasinTem;

    
    protected DeviceCategory mDeviceCategory;


    @Override
    public int getLayoutId() {
        return R.layout.fragment_healthbasin;
    }


    public static ISupportFragment newInstance(DeviceCategory mainItem) {
        Bundle args = new Bundle();
        args.putParcelable(ARG_HEALTHBASIN, mainItem);
        HealthBasinFragment fragment = new HealthBasinFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void init(View rootView) {
        mDeviceCategory = getArguments().getParcelable(ARG_HEALTHBASIN);
        mTvPage.setText(mDeviceCategory.getName());
    }

    @Override
    public void onResume() {
        super.onResume();
        if (mDeviceCategory != null) {
            AppManager.getInstance(getContext()).mSelectDeviceCategory = mDeviceCategory;
        }
    }

    @OnClick({R.id.btn_back, R.id.tv_back, R.id.btn_healthbasin_switch, R.id.btn_healthbasin_mode, R.id.btn_healthbasin_timing, R.id.btn_healthbasin_control, R.id.btn_healthbasin_tem,R.id.btn_healthbasin_bubble, R.id.btn_healthbasin_spa})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_back:
                doBack();

                break;
            case R.id.tv_back:
                doBack();

                break;
            case R.id.btn_healthbasin_switch:
                AppManager.getInstance(mainActivity).commandAdvertise("01",mDeviceCategory.getFamilyId(),mDeviceCategory.getGroupId(),"01000000","000000",mCurrFamily.getSeed(),mCurrFamily.getFeedback(),1,"7209");

                break;
            case R.id.btn_healthbasin_mode:
                AppManager.getInstance(mainActivity).commandAdvertise("01",mDeviceCategory.getFamilyId(),mDeviceCategory.getGroupId(),"02000000","000000",mCurrFamily.getSeed(),mCurrFamily.getFeedback(),1,"7209");

                break;
            case R.id.btn_healthbasin_timing:
                AppManager.getInstance(mainActivity).commandAdvertise("01",mDeviceCategory.getFamilyId(),mDeviceCategory.getGroupId(),"03000000","000000",mCurrFamily.getSeed(),mCurrFamily.getFeedback(),1,"7209");

                break;
            case R.id.btn_healthbasin_control:
                AppManager.getInstance(mainActivity).commandAdvertise("01",mDeviceCategory.getFamilyId(),mDeviceCategory.getGroupId(),"04000000","000000",mCurrFamily.getSeed(),mCurrFamily.getFeedback(),1,"7209");

                break;
            case R.id.btn_healthbasin_bubble:
                AppManager.getInstance(mainActivity).commandAdvertise("01",mDeviceCategory.getFamilyId(),mDeviceCategory.getGroupId(),"05000000","000000",mCurrFamily.getSeed(),mCurrFamily.getFeedback(),1,"7209");

                break;
            case R.id.btn_healthbasin_spa:
                AppManager.getInstance(mainActivity).commandAdvertise("01",mDeviceCategory.getFamilyId(),mDeviceCategory.getGroupId(),"06000000","000000",mCurrFamily.getSeed(),mCurrFamily.getFeedback(),1,"7209");

                break;
            case R.id.btn_healthbasin_tem:
                AppManager.getInstance(mainActivity).commandAdvertise("01",mDeviceCategory.getFamilyId(),mDeviceCategory.getGroupId(),"07000000","000000",mCurrFamily.getSeed(),mCurrFamily.getFeedback(),1,"7209");

                break;
        }
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
        mDeviceCategory = null;
    }


}